package com.googlecode.tabletags.views.jsp.ui;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.Component;

import com.googlecode.tabletags.components.SortableHeader;
import com.opensymphony.xwork2.util.ValueStack;

/**
 * @see SortableHeader
 */
public class SortableHeaderTag extends AbstractURLComponentTag {
    
    // sort column attributes
    protected String sortKey;
    protected String sortOrder;
    protected String sortable;

    /**
     * @see org.apache.struts2.views.jsp.ComponentTagSupport#getBean(com.opensymphony.xwork2.util.ValueStack,
     *      javax.servlet.http.HttpServletRequest,
     *      javax.servlet.http.HttpServletResponse)
     */
    public Component getBean(ValueStack stack, HttpServletRequest req,
        HttpServletResponse res) {
        return new SortableHeader(stack, req, res);
    }

    /**
     * @see com.opensymphony.webwork.views.jsp.ui.AbstractUITag#populateParams()
     */
    protected void populateParams() {
        super.populateParams();

        SortableHeader sortableHeader = ((SortableHeader) component);
        sortableHeader.setSortKey(sortKey);
        sortableHeader.setSortOrder(sortOrder);
        sortableHeader.setSortable(sortable);
    }

    public void setSortKey(String sortKey) {
        this.sortKey = sortKey;
    }

    public void setSortable(String sortable) {
        this.sortable = sortable;
    }

    public void setSortOrder(String sortOrder) {
        this.sortOrder = sortOrder;
    }
}
